﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TinyTeam.UI;

public class GameManager : MonoBehaviour
{
    public static GameManager instance;
    private Dictionary<int, DaTiData> daTiDatas;
    private Dictionary<int, TalkData> talkData;


    
    private void Awake()
    {
        instance = this;
    }
    void Start()
    {
       

    }
    //解析对话Json
    public Dictionary<int, TalkData> TalkData
    {
        get
        {
            if (talkData == null)
            {
                talkData = new Dictionary<int, TalkData>();
                string str = Resources.Load<TextAsset>("Data/TalkData").text;
                List<TalkData> lst = LitJson.JsonMapper.ToObject<List<TalkData>>(str);
                foreach (var item in lst)
                {
                    talkData.Add(item.id, item);
                }
            }

            return talkData;
        }
    }
    //解析答题Json
    public Dictionary<int, DaTiData> DaTiDatas
    {
        get
        {
            if (daTiDatas == null)
            {
                daTiDatas = new Dictionary<int, DaTiData>();
                string str = Resources.Load<TextAsset>("Data/DaTiData").text;
                List<DaTiData> lst = LitJson.JsonMapper.ToObject<List<DaTiData>>(str);
                foreach (var item in lst)
                {
                    daTiDatas.Add(item.id, item);
                }
            }

            return daTiDatas;
        }
    }
}